<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Starting Nagios</title>

<STYLE type="text/css">
<!--
        .Default { font-family: verdana,arial,serif; font-size: 8pt; }
        .PageTitle { font-family: verdana,arial,serif; font-size: 12pt; font-weight: bold; }
-->      
</STYLE>

</head>

<body bgcolor="#FFFFFF" text="black" class="Default">

<p>
<div align="center">
<h2 class="PageTitle">Starting Nagios</h2>
</div>
</p>
<hr>

<p>
<font color="red"><strong>IMPORTANT:</strong></font>  Before you actually start Nagios, you'll have to make sure that you have <a href="config.html">configured</a> it properly and <a href="verifyconfig.html">verified the config data</a>! </p>

<p>
<strong><u>Methods For Starting Nagios</u></strong>
</p>

<p>
There are basically four different ways you can start Nagios:
</p>
<p>
<ol>
<li>Manually, as a foreground process (useful for initial testing and debugging)
<li>Manually, as a background process
<li>Manually, as a daemon
<li>Automatically at system boot
</ol>
</p>

<p>
Let's examine each method briefly...
</p>

<p>
<strong><u>Running Nagios Manually as a Foreground Process</u></strong>
</p>

<p>
If you enabled the debugging options when running the configure script (and recompiled Nagios), this would
be your first choice for testing and debugging.  Running Nagios as a foreground process at a shell
prompt will allow you to more easily view what's going on in the monitoring and notification processes.
To run Nagios as a foreground process for testing, invoke Nagios like this...
</p>
<p>
<strong><font color="red">/usr/local/nagios/bin/nagios &lt;main_config_file&gt;</font></strong>
</p>
<p>
Note that you must specify the path/filename of the <a href="configmain.html">main configuration file</a> (i.e. <i>/usr/local/nagios/etc/nagios.cfg</i>) on the command line.
</p>
<p>
To stop Nagios at any time, just press CTRL-C.  If you've enabled the debugging options you'll probably want to
redirect the output to a file for easier review later.
</p>

<p>
<strong><u>Running Nagios Manually as a Background Process</u></strong>
</p>
<p>
To run Nagios as a background process, invoke it with an ampersand as follows...
</p>
<p>
<strong><font color="red">/usr/local/nagios/bin/nagios &lt;main_config_file&gt; &amp;</font></strong>
</p>
<p>
Note that you must specify the path/filename of the <a href="configmain.html">main configuration file</a> (i.e. <i>/usr/local/nagios/etc/nagios.cfg</i>) on the command line.
</p>

<p>
<strong><u>Running Nagios Manually as a Daemon</u></strong>
</p>
<p>
In order to run Nagios in daemon mode you must supply the <b>-d</b> switch on the command line as follows...
</p>
<p>
<strong><font color="red">/usr/local/nagios/bin/nagios -d &lt;main_config_file&gt;</font></strong>
</p>
<p>
Note that you must specify the path/filename of the <a href="configmain.html">main configuration file</a> (i.e. <i>/usr/local/nagios/etc/nagios.cfg</i>) on the command line.
</p>

<p>
<strong><u>Running Nagios Automatically at System Boot</u></strong>
</p>
<p>
When you have tested Nagios and are reasonably sure that it is not going to crash, you will probably
want to have it start automatically at boot time.  To do this (in Linux) you will have to create a startup script
in your <b>/etc/rc.d/init.d/</b> directory.  You will also have to create a link to the script in
the runlevel(s) that you wish to have Nagios to start in.  I'll assume that you know what I'm talking about and are able to do this.
</p>
<p>
A sample init script (named <b>daemon-init</b>) is created in the base directory of the Nagios distribution when you run the configure script.  You can install the sample script to your /etc/rc.d/init.d directory using the '<font color="red"><strong>make install-init</strong></font>' command, as outlined in the <a href="installing.html#installing">installation</a> instructions.
</p>
<p>
The sample init scripts are designed to work under Linux, so if you want to use them under FreeBSD, Solaris, etc. you may have to do a little hacking...
</p>

<p>
<strong><u>Stopping and Restarting Nagios</u></strong>
</p>

<p>
Directions on how to stop and restart Nagios can be found <a href="stoprestart.html">here</a>.
</p>

<hr>

</body>
</html>
